package com.chongchong.flow.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chongchong.core.mp.base.BaseServiceImpl;
import com.chongchong.flow.entity.FlowTaskExt;
import com.chongchong.flow.mapper.FlowTaskExtMapper;
import com.chongchong.flow.service.IFlowTaskExtService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 流程任务扩展数据操作服务类。
 *
 * @author
 */
@Slf4j
@Service("flowTaskExtService")
//@AllArgsConstructor
public class FlowTaskExtServiceImpl extends BaseServiceImpl<FlowTaskExtMapper, FlowTaskExt> implements IFlowTaskExtService {
//	@Autowired(required = false)
//	private FlowTaskExtMapper flowTaskExtMapper;

	/**
	 * 返回当前Service的主表Mapper对象。
	 *
	 * @return 主表Mapper对象。
	 */
//	@Override
//	protected BaseDaoMapper<FlowTaskExt> mapper() {
//		return flowTaskExtMapper;
//	}

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveBatch(List<FlowTaskExt> flowTaskExtList) {
        if (CollUtil.isNotEmpty(flowTaskExtList)) {
			baseMapper.insertList(flowTaskExtList);
        }
    }

    @Override
    public FlowTaskExt getByProcessDefinitionIdAndTaskId(String processDefinitionId, String taskId) {
        FlowTaskExt filter = new FlowTaskExt();
        filter.setProcessDefinitionId(processDefinitionId);
        filter.setTaskId(taskId);
        return baseMapper.selectOne(new QueryWrapper<>(filter));
    }

    @Override
    public List<FlowTaskExt> getByProcessDefinitionId(String processDefinitionId) {
        FlowTaskExt filter = new FlowTaskExt();
        filter.setProcessDefinitionId(processDefinitionId);
        return baseMapper.selectList(new QueryWrapper<>(filter));
    }
}
